<?php
use \pft\Member\MemberAccount as Mem;
if($_SESSION['memberID']!=1 && !($_SESSION['sid']==1 && strpos($_SESSION['qx'],'mems'))){
    exit("不合法的身份访问！");
}

include '/var/www/html/new/d/common/autoload.php';
include COMMONPATH.'page.php';
include '/var/www/html/new/d/module/common/Db.class.php';
$dbConf = include '/var/www/html/new/d/module/common/db.conf.php';// 远端服务器配置信息

\PFT\Db::Conf($dbConf['remote_1']);
$db = \PFT\Db::Connect();

if (isset($_POST['id'])) {
	//删除记录
	$stmt = $db->prepare('delete from pft_page_hit where id = :id limit 1');
	if ($stmt->execute(array(':id' => $_POST['id']))) {
		$return = array('status' => 1, 'info' => '删除成功');
	} else {
		$return = array('status' => 0, 'info' => '删除失败,请重试');
	}
	echo json_encode($return);
} else {
	$where = '';	//模糊查询
	if (isset($_GET['page_name']) && $_GET['page_name']) {
		$where .= 'page_name like' . "'%{$_GET['page_name']}%'";
	}
	if (isset($_GET['page_identify']) && $_GET['page_identify']) {
        if ($where) $where .= ' and ';
		$where .= 'page_identify like' . "'%{$_GET['page_identify']}%'";
	}
    if (isset($_GET['page_type']) && $_GET['page_type'] != 'all') {
        if ($where) $where .= ' and ';
        $where .= 'page_type = ' . (int)$_GET['page_type'];
    }
	$where = $where ? $where : 1;

	//分页功能
	$stmt = $db->query("select count(id) from pft_page_hit where ".$where);
	$data['total'] = $stmt->fetchColumn();
	$data['page'] = isset($_GET['currentPage']) && $_GET['currentPage'] > 0 ? $_GET['currentPage'] : 1;
	$data['size'] = isset($_GET['pageSize']) && $_GET['pageSize'] > 0 ? $_GET['pageSize'] : 20;
	$limit = ($data['page'] - 1) * $data['size'] . ',' . $data['size'];
	$sql = sprintf('select * from pft_page_hit where %s order by hits desc limit %s', $where, $limit);
	$data['list'] = \PFT\Db::fetchAll($sql);

	include 'page_statics.tpl';
}
\PFT\Db::Close();

